package hcn.sync.exception;


import ctd.net.rpc.Client;
import hcn.sync.core.Const;
import hcn.sync.core.row.ResultMeta;

/**
 * Created by chase on 2016/10/24.
 */
public class DataSyncException extends SynchronizeException {

    public DataSyncException(int code) {
        super(code);
    }

    public DataSyncException(int code, String msg) throws SynchronizeException {
        super(code, msg);
    }

    public DataSyncException(ResultMeta rowMeta) throws SynchronizeException {
        super(rowMeta.getCode(), rowMeta.getMsg());
        this.rpcInvoke(rowMeta);
    }

    public void rpcInvoke(final ResultMeta rowMeta) {
        rowMeta.incrementLinesRejected();
        try {
            Client.rpcInvoke(Const.domianName + "." + Const.logServiceId, Const.excpMethodName, rowMeta);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }

    public DataSyncException(Throwable e) {
        super(e);
    }

    public DataSyncException(Throwable e, int code) {
        super(e, code);
    }

    public DataSyncException(Throwable e, String msg) {
        super(e, msg);
    }

    public DataSyncException(Throwable e, int code, String msg) {
        super(e, code, msg);
    }

    public DataSyncException(String msg) {
        super(msg);
    }

}

